<div>
    <ol class="breadcrumb" >
        <li> <i class="fa fa-anchor"></i>
            &nbsp;电桩管理
        </li>
        <li>电桩列表</li>
    </ol>
    <div class="panel">
        <div class="panel-heading" >
            <i class="fa fa-list"></i>
            &nbsp;&nbsp;电桩信息表
        </div>
        <form class="search-form" action={:U("Evcharger/index")} method="get">
            <div class="panel-body search-panel-body"  >
                <div class="col-xs-4" style=" width:500px;">
                    <div class="input-group">
                        <span class="input-group-addon" style="width:80px;">所在地</span>
                        <select id="location-f" name="location_f_1" class="form-control" style="width:139px;">
                            <option value="0">--</option>
                            <volist name="china" id="vo">
                                <option value="{$vo.code}">{$vo.name}</option>
                            </volist>
                        </select>

                        <select id="location-s" name="location_s_1" class="form-control" style="width:125px;border-left:0">
                            <option value="0">--</option>
                            <volist name="china" id="vo">
                                <volist name="vo['area']" id="vovo">
                                    <option value="{$vovo.code}" class="{$vo.code}" >{$vovo.name}</option>
                                </volist>
                            </volist>
                        </select>

                        <select id="location-t" name="location_t_1" class="form-control required" style="width:125px;border-left:0">
                            <option value="0">--</option>
                            <volist name="china" id="vo">
                                <volist name="vo['area']" id="vovo">
                                    <volist name="vovo['area']" id="vovovo">
                                        <option value="{$vovovo.code}" class="{$vovo.code}" >{$vovovo.name}</option>
                                    </volist>
                                </volist>
                            </volist>
                        </select>
                    </div>
                </div>
                <div class="col-xs-5 search-col">
                    <div class="input-group">
                        <span class="input-group-addon">运营二维码</span>
                        <input type="text" name="evc_number" class="form-control" maxlength="12" value="{$_GET['evc_number']}" placeholder="运营二维码">
                        <span class="input-group-addon">设备地址</span>
                        <input type="text" name="key_link" class="form-control" maxlength="16" value="{$_GET['key_link']}" placeholder="设备地址">
                    </div>
                </div>
                <div class="col-xs-1 search-col">
                    <button  type="submit" class="btn btn-warning">
                        <i class="fa fa-search"></i>
                        &nbsp;搜索
                    </button>
                </div>
            </div>
        </form>
        <table  class="table table-bordered table-striped table-mcit" >
            <thead>
            <tr>
                <th>
                    <button class='btn btn-block btn-mcit'>选择</button>
                </th>
                <th >
                    <empty name="is_order_name">
                        <button class='btn btn-block btn-mcit' type='submit' name='order_name' value=''>ID</button>
                        <else/>
                        <button class='btn btn-block btn-mcit btn-mcit-active'  type='submit' name='order_name' value=''>
                            <if condition="$order_name eq 1">
                                <i class="fa fa-chevron-down"></i>
                                <else/>
                                <i class="fa fa-chevron-up"></i>
                            </if>
                            &nbsp;ID
                        </button>
                    </empty>
                </th>
                <th>
                    <empty name="is_order_stu_num">
                        <button class='btn btn-block btn-mcit' type='submit' name='order_stu_num' value=''>站点名称</button>
                        <else/>
                        <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' name='order_stu_num' value=''>
                            <if condition="$order_stu_num eq 1">
                                <i class="fa fa-chevron-down"></i>
                                <else/>
                                <i class="fa fa-chevron-up"></i>
                            </if>
                            &nbsp;站点名称
                        </button>
                    </empty>
                </th>
                <th>
                    <empty name="is_order_stu_num">
                        <button class='btn btn-block btn-mcit' type='submit' name='order_stu_num' value=''>所在区域</button>
                        <else/>
                        <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' name='order_stu_num' value=''>
                            <if condition="$order_stu_num eq 1">
                                <i class="fa fa-chevron-down"></i>
                                <else/>
                                <i class="fa fa-chevron-up"></i>
                            </if>
                            &nbsp;所在区域
                        </button>
                    </empty>
                </th>
                <th>
                    <empty name="is_order_stu_num">
                        <button class='btn btn-block btn-mcit' type='submit' name='order_stu_num' value=''>运营二维码</button>
                        <else/>
                        <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' name='order_stu_num' value=''>
                            <if condition="$order_stu_num eq 1">
                                <i class="fa fa-chevron-down"></i>
                                <else/>
                                <i class="fa fa-chevron-up"></i>
                            </if>
                            &nbsp;运营二维码
                        </button>
                    </empty>
                </th>
                <th>
                    <empty name="is_order_idcard">
                        <button class='btn btn-block btn-mcit' type='submit' name='order_idcard' value=''>设备地址</button>
                        <else/>
                        <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' name='order_idcard' value=''>
                            <if condition="$order_idcard eq 1">
                                <i class="fa fa-chevron-down"></i>
                                <else/>
                                <i class="fa fa-chevron-up"></i>
                            </if>
                            &nbsp;设备地址
                        </button>
                    </empty>
                </th>
                <th>
                    <empty name="is_order_major">
                        <button class='btn btn-block btn-mcit' type='submit' name='order_major' value=''>类型</button>
                        <else/>
                        <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' name='order_major' value=''>
                            <if condition="$order_major eq 1">
                                <i class="fa fa-chevron-down"></i>
                                <else/>
                                <i class="fa fa-chevron-up"></i>
                            </if>
                            &nbsp;类型
                        </button>
                    </empty>
                </th>
                <th>
                    <empty name="is_order_tel">
                        <button class='btn btn-block btn-mcit' type='submit' name='order_tel' value=''>属性</button>
                        <else/>
                        <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' name='order_tel' value=''>
                            <if condition="$order_tel eq 1">
                                <i class="fa fa-chevron-down"></i>
                                <else/>
                                <i class="fa fa-chevron-up"></i>
                            </if>
                            &nbsp;属性
                        </button>
                    </empty>
                </th>
                <th>
                    <empty name="is_order_household">
                        <button class='btn btn-block btn-mcit' type='submit' name='order_household' value=''>安装时间</button>
                        <else/>
                        <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' name='order_household' value=''>
                            <if condition="$order_household eq 1">
                                <i class="fa fa-chevron-down"></i>
                                <else/>
                                <i class="fa fa-chevron-up"></i>
                            </if>
                            &nbsp;建立时间
                        </button>
                    </empty>
                </th>
                <th>
                    <empty name="is_order_edit_self">
                        <button class='btn btn-block btn-mcit' type='submit' name='order_edit_self' value=''>操作</button>
                        <else/>
                        <button class='btn btn-block btn-mcit btn-mcit-active' type='submit' name='order_edit_self' value=''>
                            <if condition="$order_edit_self eq 1">
                                <i class="fa fa-chevron-down"></i>
                                <else/>
                                <i class="fa fa-chevron-up"></i>
                            </if>
                            &nbsp;操作
                        </button>
                    </empty>
                </th>
            </tr>
            </thead>
            <tbody id="DataTableContent">
            <empty name="ev_char">
                <td colspan="99" style="text-align:center" class="danger"> <strong><i class="fa fa-meh-o"></i>
                    &nbsp;&nbsp;当前条件下没有数据</strong>
                </td>
                <else />
                <volist name="ev_char" id="data">
                    <tr class="lists">
                        <td><input type="checkbox"  value="{$data.id}"/></td>
                        <td>{$data.id}</td>
                        <td title="{$data.plant_name}">{$data.plant_name_text}</td>
                        <td title="{$data.plantinfo.address}">{$data.region_text}</td>
                        <td>
                            <if condition="$data.evc_number neq ''">
                                {$data.evc_number}
                                <else />
                                <a class="btn  btn-xs create"  data-code="{$data.key_link}"  data-id="{$data.id}" data-info="确定生成【运营二维码】吗？">
                                    <img src="__PUBLIC__/img/create.png" alt="启动"/>
                                </a>
                            </if>
                        </td>
                        <td>{$data.key_link}</td>
                        <td><if condition="$data.evc_type eq 1">直流<elseif condition="$data.evc_type eq 3" />混合<else />交流</if></td>
                        <td><if condition="$data.evc_quantity eq 1">单枪<else />双枪</if></td>
                        <td>{$data.sys_creat_time}</td>
                        <td>
                            <a class="btn btn-success btn-sm" href="__URL__/detail/id/{$data.id}">
                                <i class="fa fa-eye"></i>
                                &nbsp;查看
                            </a>
                            <a class="btn btn-warning btn-sm" href="__URL__/update/id/{$data.id}">
                                <i class="fa fa-edit"></i>
                                &nbsp;修改
                            </a>
                        </td>
                    </tr>
                </volist>
            </empty>
            <tr>
                <td colspan="99">
                    <input type="button" value="全选"   class="btn" id="selectAll">
                    <input type="button" value="全不选" class="btn" id="unSelect">
                    <input type="button" value="反选"   class="btn" id="reverse">
                    <input type="button" value="批量修改站点" class="btn" id="getValue">
                </td>
            </tr>
            <tr>
                <td colspan="99" style="text-align:center">
                    <ul class="pagination">{$pageView}</ul>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
<import file="js.jquery#chained" />
<script type="text/javascript">
    $(document).ready(function () {

        //生成运营二维码
        $(document).on("click",'.create',function(){
            var aobj     = $(this).parent();
            var aid      = $(this).attr("data-id");//ID
            var ainfo    = $(this).attr("data-info");
            var key_link = $(this).attr("data-code");//key_link
            //alert(key_link);
            alertify.confirm(ainfo, function (i) {
                if (i) {
                    $.ajax({
                        type: "POST",
                        url:  '{:U("Evcharger/createEvcNumber")}',
                        data: {id:aid,key_link:key_link},
                        dataType: "json",
                        success: function(data){
                            if(data.state==100){
                                alertify.success(data.msg);
                                location.reload();
                            }else{
                                alertify.error(data.msg);
                            }
                        }
                    });
                } else {
                    alertify.error("取消操作！");
                }
            }, "mcit_default");
        });

        $("#location-s").chained("#location-f");
        $("#location-t").chained("#location-s");


        //全选
        $("#selectAll").click(function () {
            $(".lists :checkbox").prop("checked", true);
        });
        //全不选
        $("#unSelect").click(function () {
            $(".lists :checkbox").prop("checked", false);
        });
        //反选
        $("#reverse").click(function () {
            $(".lists :checkbox").each(function () {
                $(this).prop("checked", !$(this).prop("checked"));
            });
        });
        //批量修改
        $("#getValue").click(function(){
            var valArr = new Array;
            $("input[type='checkbox']:checked").prop("checked", function(i) {
                valArr[i] = $(this).val();
            });
            var vals = valArr.join(',');
            if(vals == ''){
                alert("请选择要处理的数据!");
            }else{
                //alert(vals);
                location.href="__URL__/editplant/charids/"+vals;
            }
        });
    });
</script>